 <?php
function search($score, $filter)
{   
    $half = floor(count($filter) / 2); // 取出中間数

    // 判断积分在哪个区间
    if ($score <= $filter[$half - 1]['max']) {
        $filter = array_slice($filter, 0 , $half);
    } else {
        $filter = array_slice($filter, $half , count($filter));
    }

    // 继续递归直到只剩一个元素
    if (count($filter) != 1) {
        $filter = search($score, $filter);
    }

    return $filter;
}


$filter = [
    ['level' => 0, 'min' => 0, 'max' => 200],
    ['level' => 1, 'min' => 201, 'max' => 1000],
    ['level' => 2, 'min' => 1001, 'max' => 3000],
    ['level' => 3, 'min' => 30011, 'max' => 8000],
    ['level' => 4, 'min' => 8001, 'max' => 10000],
    ['level' => 5, 'min' => 1001, 'max' => 20000],
    ['level' => 6, 'min' => 20001, 'max' => 30000],
    ['level' => 7, 'min' => 40001, 'max' => 50000],
    ['level' => 8, 'min' => 50001, 'max' => 60000],
    ['level' => 9, 'min' => 60001, 'max' => 99999999],
    
];

$result = search($_SESSION['exp'], $filter);
$dengji= current($result)['level'];
?>
<link rel="stylesheet" type="text/css" href="style/yj_top.css" />
<div id="header">
    <div class="publicHd">
        <?php 
            if (isset($_SESSION['usersid'])){
        ?>
            <div class="login-section clearfix">
                <div class="mc-section">
                    <div class="right fr clearfix logged">
                        <div class="loggedUser fl">您好
                            <span class="userName"><?php echo $_SESSION['nickname'] . "({$_SESSION['usersid']})" ?></span>，欢迎回来
                        </div>
                        <div class="tips-block inline fl noMgRt">
                            <a href="member.php" class="strongColor">我的账户</a>
                            <span class="hld">宝币：</span>
                            <span class="strongColor" id="hld"><?php echo Trans($_SESSION['points'])?></span>
                            <span class="yh">银行：</span>
                            <span class="strongColor" id="yh"><?php echo Trans($_SESSION['bankpoints'])?></span>
                            <span class="split-line"></span>
                            <a href="member.php?yj_act=onlinepay" id="topRecharge">充值</a>
                            <span class="split-line"></span>
                            <a href="member.php?yj_act=Withdrawals" id="topWithdraw">提现</a>
                            <span class="split-line"></span>
                            <a href="slogin.php?act=logout" id="loginOut">[退出]</a>
                        </div>
                    </div>
                </div>
            </div>
        <?php 
            }else{
        ?>
            <div class="login-section clearfix">
                <div class="mc-section">
                    <div class="right fr clearfix">
                            <div class="iptItem">
                                <input class="publicIpt" type="text" placeholder="请输入邮箱/手机号" name="userName" id="username">
                            </div>
                            <div class="iptItem">
                                <input class="publicIpt" type="password" placeholder="密码" name="loginPwd" id="pass">
                            </div>
                            <div class="iptItem v-codeIpt">
                                <input class="publicIpt v-codeIpt" type="text" placeholder="验证码" name="captcha" id="vcode">
                            </div>
                            <div class="v-codeBox fl">
                            <img src="vcode.php" width="80" height="30" onClick="this.src='vcode.php?tm=' + Math.random();" />
                            </div>
                        <div class="publicBtn bg-yellow fl loginBtn" id="login">登录</div>
                        <div class="tips-block inline fl noMgRt">
                            <a href="reg.php">免费注册</a><span class="split-line"></span>
                            <a href="forgetpass.php" class="noMgRt" id="forgetPsw">忘记密码？</a>
                        </div>
                    </div>
                </div>
            </div>
        <?php 
            }
        ?>
        <div class="navigater-section">
            <div class="mc-section clearfix">
                <div class="leftLogo fl">
                    <div class="logoWrap fl">
                        <a href="<?php echo($yj_config[4]['yj_url']) ?>">
                        <img src="<?php echo($yj_config[4]['yj_value']) ?>" alt="" style="height: 77px;width: 205px;">
                        </a>
                        <div class="highLight"></div>
                    </div>
                    <div class="logoText fl" style="display: none;"><img src="/img/logoText.png" alt=""></div>
                </div>
                <div class="rightNav fr" id="nav">
                    <a href="index.php" class="navItem">首頁</a>
                    <div class="splitLine"></div>
                    <a href="/game.php" class="navItem" id="gameIndex">游戏乐园
                        <div class="hotIcon"></div>
                    </a>
                    <div class="splitLine"></div>
                    <a href="/member.php" class="navItem" id="personal"> 会员中心</a>
                    <div class="splitLine"></div>
                    <a href="/rankings.php" class="navItem">牛人榜</a>
                    <div class="splitLine"></div>
                    <a href="merchants.php" class="navItem">合作商家</a>
                    <div class="splitLine"></div>
                    <a href="gift.php" class="navItem">商品兑换</a>
                    <div class="splitLine"></div>
                    <a href="/goods.php" class="navItem">推荐好友</a>
                    <div class="splitLine"></div>
                    <a href="/active.php" class="navItem">活动中心</a>
                </div>
            </div>
        </div>
    </div>
</div>

<script language="javascript">  
    var obj=null;
    var As=document.getElementById('nav').getElementsByTagName('a');
    obj = As[0];
    for(i=1;i<As.length;i++){
        if(window.location.href.indexOf(As[i].href)>=0)
        obj=As[i];
    }
    obj.className = "navItem active";
</script>




    



